<?php
chdir("../../");
require 'runtime.php';

$city = filter_input(INPUT_POST, "city");
$s = filter_input(INPUT_POST, "s", FILTER_SANITIZE_NUMBER_INT);

if(!$s) $s = 1;

if($s < 6){
	
	if(!strlen($city)) ajax_result("error", "请输入城市名称！");
	// 将城市名称转换成城市ID
	require 'library/defined.cityid.php';
	// 提取城市天气
	$cityid = "";
	$city_py = @Pinyin($city);
	if(array_key_exists($city_py, $CITYID)){
		$cityid = $CITYID[$city_py];
	}else{
		ajax_result("error", "获取城市ID失败，请勿输入后面的“市”！");
	}
	
	$url = "http://w.mdeve.com/{$cityid}". ($s==1 ? "" : ",{$s}"). ".ics";
	
}else{
	
	$url = "http://w.mdeve.com/n{$s}.ics";
	
}
ajax_result("successful", $url);




